<?php

namespace app\office\model;

use think\Model;

class ModuleStatic extends Model
{
  // 获取无限分类结构数组organization_tree
    public static function getTree($parent_id=0,$level=0){
      $tree=array();
      foreach(self::select() as $key=>$row){
        if($row['parent_id']==$parent_id){
          $row['level']=$level;
          $tree[]=$row;
          $tree=array_merge($tree,self::getTree($row['id'],$level+1));
        }
      }
      return $tree;
    }
      //在模块内再次确保开启自动时间戳;
    protected $autoWriteTimestamp='datetime';
  
    //设置自动时间戳格式为datetime格式;
    protected $type=[
      'create_time'=>'datetime',
      'update_time'=>'datetime',
    ];
  
  //
    /**
  * 多对多关系资源
  *
  * @param  
  * @return 
  */
  public function position(){
    return $this->belongsToMany('Position','position_module_static');
  }
}
